﻿using System;
using ReadyApps.Data.Wiki;

namespace ReadyApps.Wiki.ViewModels
{
    [Serializable]
    class PageSettingsViewModel : IWikiViewModel
    {
        #region Properties

        public bool CanManagePublishing { get; private set; }

        public bool CanManageRevisions { get; private set; }

        public PublicationSettings PublicationSettings { get; private set; }

        public RetentionSettings RetentionSettings { get; private set; }

        #endregion

        #region Constructor

        public PageSettingsViewModel(bool canManagePublishing, bool canManageRevisions,
            PublicationSettings publicationSettings, RetentionSettings retentionSettings)
        {
            // Settings are allowed to be null to avoid looking the settings up if the database
            if (canManagePublishing && publicationSettings == null)
            {
                throw new ArgumentNullException("publicationSettings");
            }
            if (canManageRevisions && retentionSettings == null)
            {
                throw new ArgumentNullException("retentionSettings");
            }
            CanManagePublishing = canManagePublishing;
            CanManageRevisions = canManageRevisions;
            PublicationSettings = publicationSettings;
            RetentionSettings = retentionSettings;
        }

        #endregion
    }
}
